package com.ep.modules.app.controller;

import com.ep.common.annotation.SysLog;
import com.ep.common.utils.PageUtils;
import com.ep.common.utils.R;
import com.ep.common.validator.ValidatorUtils;
import com.ep.modules.app.entity.AppCourseContent;
import com.ep.modules.app.service.AppCourseContentService;
import java.util.Map;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/course_content")
public class AppCourseContentController {
    @Autowired
    private AppCourseContentService appCourseContentService;

    @GetMapping("/list")
    public R list(Map<String, Object> params) {
        PageUtils page = appCourseContentService.queryPage(params);
        return R.ok().put("page", page);
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable Long id) {
        AppCourseContent appcoursecontent = appCourseContentService.getById(id);
        return R.ok().put("appcoursecontent", appcoursecontent);
    }

    @SysLog("保存AppCourseContent")
    @PostMapping("/save")
    public R save(@RequestBody AppCourseContent appcoursecontent) {
        ValidatorUtils.validateEntity(appcoursecontent);
        appCourseContentService.save(appcoursecontent);
        return R.ok();
    }

    @SysLog("修改AppCourseContent")
    @PostMapping("/update")
    public R update(@RequestBody AppCourseContent appcoursecontent) {
        ValidatorUtils.validateEntity(appcoursecontent);
        appCourseContentService.update(appcoursecontent);
        return R.ok();
    }

    @SysLog("删除AppCourseContent")
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        appCourseContentService.deleteBatch(ids);
        return R.ok();
    }
}